package com.itheima.spring.spring;

import com.itheima.spring.service.QuestionService;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.stereotype.Component;

/**
 * @author ：sean
 * @date ：Created in 2020/8/11
 * @description ：
 * @version: 1.0
 */
public class HmImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
	@Override
	public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
		System.out.println("HmImportBeanDefinitionRegistrar...");
		// importingClassMetadata 被import导入的类的注解信息
		GenericBeanDefinition rootBeanDefinition = new GenericBeanDefinition();
		rootBeanDefinition.setBeanClass(QuestionService.class);
		registry.registerBeanDefinition("questionService",rootBeanDefinition);
	}
}
